package org.hydrakyoufeng.vv.user;


import org.hydrakyoufeng.vv.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @ResponseBody
    @RequestMapping("login")
    public Result login(@RequestBody @Validated UserBean user, BindingResult result) {
        if (result.hasErrors()) {
            return Result.fail("参数错误");
        }
        return userService.login(user);
    }
}
